package com.bw.zh.view

import android.os.Bundle
import android.view.View
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.widget.ProgressBar
import androidx.activity.ComponentActivity
import com.bw.zh.R
import org.checkerframework.checker.index.qual.GTENegativeOne

/**
 *
 * @ClassName: WebViewActivity
 * @Description: java类作用描述
 * @Author: zhangyanchao
 * @CreateDate: 2024/9/28 10:54 AM
 * @Version: 1.0
 */
class WebViewActivity2 : ComponentActivity() {
    lateinit var webView: WebView
    lateinit var pb: ProgressBar
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_webview)
        webView = findViewById<WebView>(R.id.webview)
        pb = findViewById<ProgressBar>(R.id.pb)
        webView.webChromeClient = object :WebChromeClient(){
            override fun onProgressChanged(view: WebView?, newProgress: Int) {
                super.onProgressChanged(view, newProgress)
                if(newProgress<100){
                    pb.progress = newProgress
                }else{
                    pb.visibility = View.GONE
                }

            }
        }
        //加载网页地址
        webView.loadUrl("https://m.qfang.com/shenzhen/user/privacy-protocol.html")

    }
}